package org.example.classtopia.Common.Result;

import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T>{
    private Integer code;//状态码
    private String message;//信息
    private T data;//数据

    public static <T> Result<T> success(T data){
        return new Result<T>(200,"success",data);
    }

    public static Result<Void> success(){
        return new Result<>(200,"success",null);
    }

    public static <T> Result<T> success(String message, T data){
        return new Result<>(200,message,data);
    }

    public static <T> Result<T> error(Integer code, String message){
        return new Result<T>(code,message,null);
    }

    public static <T> Result<T> error(String message){
        return new Result<T>(500,message,null);
    }

    public static <T> Result<T> error(String message, T data){
        return new Result<>(200,message,null);
    }
}
